unit MusteriSikayetFormuEk;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, XPMan, StdActns, ActnList, StdCtrls, ComCtrls,
  wwriched, wwdblook, Buttons, ExtCtrls, dbcgrids, DB, ADODB, Mask,
  wwdbedit;

type
  TfmMusteriSikayetFormuEk = class(TfmFormClass)
    GroupBox3: TGroupBox;
    DBCtrlGrid1: TDBCtrlGrid;
    Label12: TLabel;
    Label18: TLabel;
    Panel7: TPanel;
    bEkle: TBitBtn;
    bVazgec: TBitBtn;
    bSil: TBitBtn;
    lcAksiyon: TwwDBLookupCombo;
    edYapilanlar: TwwDBRichEdit;
    btKaydet: TBitBtn;
    btYenile: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btKaydetClick(Sender: TObject);
    procedure bEkleClick(Sender: TObject);
    procedure bVazgecClick(Sender: TObject);
    procedure bSilClick(Sender: TObject);
    procedure btYenileClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure AktifPasif(TrueFalse: Boolean);

  end;

var
  fmMusteriSikayetFormuEk: TfmMusteriSikayetFormuEk;

implementation
uses MusteriTakipKarti;
{$R *.dfm}

procedure TfmMusteriSikayetFormuEk.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmMusteriSikayetFormuEk := nil;
end;

procedure TfmMusteriSikayetFormuEk.btKaydetClick(Sender: TObject);
begin
  inherited;
  if MusteriTakipKartiF.aqSikayetEk.State in [dsEdit, dsInsert] then
    if (MusteriTakipKartiF.aqSikayetEk.FieldByName('Sikayet').IsNull)
      and (MusteriTakipKartiF.aqSikayetEk.FieldByName('SikayetAciklama').IsNull) then
      MusteriTakipKartiF.aqSikayetEk.Cancel
    else
      MusteriTakipKartiF.aqSikayetEk.Post;
end;

procedure TfmMusteriSikayetFormuEk.bEkleClick(Sender: TObject);
begin
  inherited;
  btKaydet.Click;
  MusteriTakipKartiF.aqSikayetEk.Last;
  MusteriTakipKartiF.aqSikayetEk.Append;
end;

procedure TfmMusteriSikayetFormuEk.bVazgecClick(Sender: TObject);
begin
  inherited;
  if MusteriTakipKartiF.aqSikayetEk.State in [dsEdit, dsInsert] then
    MusteriTakipKartiF.aqSikayetEk.Cancel;
end;

procedure TfmMusteriSikayetFormuEk.bSilClick(Sender: TObject);
begin
  inherited;
  if MusteriTakipKartiF.aqSikayetEk.State in [dsEdit, dsInsert] then
    MusteriTakipKartiF.aqSikayetEk.Cancel
  else
    if MusteriTakipKartiF.aqSikayetEk.RecordCount > 0 then
      MusteriTakipKartiF.aqSikayetEk.Delete;
end;

procedure TfmMusteriSikayetFormuEk.btYenileClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TfmMusteriSikayetFormuEk.FormShow(Sender: TObject);
begin
  inherited;
  if (UseType in [futInsert, futEdit]) then
    AktifPasif(True)
  else
    AktifPasif(False);
end;

procedure TfmMusteriSikayetFormuEk.AktifPasif(TrueFalse: Boolean);
var
  I: integer;
begin
  for I := 0 to ComponentCount - 1 do
  begin
    if Components[I].Tag = 99 then
      Continue;

    if (Components[I] is TAction) then
      (Components[I] as TAction).Enabled := TrueFalse;

    if (Components[I] is twwdbedit) then
    begin
      (Components[I] as twwdbedit).ReadOnly := not TrueFalse;
      if TrueFalse then
        (Components[I] as twwdbedit).Color := clWindow
      else
        (Components[I] as twwdbedit).Color := clInfoBk;
    end;

    if (Components[I] is twwdblookupcombo) then
    begin
      (Components[I] as twwdblookupcombo).ReadOnly := not TrueFalse;
      if TrueFalse then
        (Components[I] as twwdblookupcombo).Color := clWindow
      else
        (Components[I] as twwdblookupcombo).Color := clInfoBk;
    end;

    if (Components[I] is TwwDBRichEdit) then
    begin
      (Components[I] as TwwDBRichEdit).ReadOnly := not TrueFalse;
      if TrueFalse then
        (Components[I] as TwwDBRichEdit).Color := clWindow
      else
        (Components[I] as TwwDBRichEdit).Color := clInfoBk;
    end;

    if (Components[I] is TBitBtn) then
      (Components[I] as TBitBtn).Enabled := TrueFalse;
  end;
end;

end.

